package com.fd.service.impl;

import com.fd.dao.CartDAO;
import com.fd.dao.ProductDAO;
import com.fd.dao.impl.CartDAOImpl;
import com.fd.dao.impl.PorductDAOImpl;
import com.fd.pojo.Cart;
import com.fd.pojo.Products;
import com.fd.service.CartService;

import java.util.List;

public class CartServiceImpl implements CartService {
    private ProductDAO productDAO=new PorductDAOImpl();
    private CartDAO cartDAO = new CartDAOImpl();

    public boolean addCart(String pid) {
        //根据pid获取商品的信息
        Products product = productDAO.findByID(pid);
        System.out.println(product.toString());
        //将商品信息传入购物车
        return cartDAO.insertGoods(product);
    }

    public List<Cart> selectCart() {
        return cartDAO.queryAll();
    }

    public boolean reGoodsCart(Integer pid) {
        return cartDAO.reCartById(pid);
    }
}
